#include <stdio.h>
int main()
{
	FILE* fpr=fopen("C:\\Users\\MSIK\\Desktop\\file.txt","r");
	FILE* fpw=fopen("output","w");
	int a,b;
	fscanf(fpr,"%d",&a);
	fscanf(fpr,"%d",&b);
	int matrix[a][b];
	int spin[b][a];
	fprintf(fpw,"%d %d\n",b,a);
	for(int i=0;i<a;i++)
	{
		for(int j=0;j<b;j++)
		{
			fscanf(fpr,"%d",&matrix[i][j]);
			spin[j][i]=matrix[i][j];
		}
	}
	for(int i=0;i<b;i++)
	{
		for(int j=0;j<a;j++)
		{
			fprintf(fpw,"%d ",spin[i][j]);
		}
		fprintf(fpw,"\n");
	}
	fclose(fpr);
	fclose(fpw);
	return 0;
}
